package com.weixing.mall.provider.support.mq;

import com.weixing.mall.redis.RedisKeyConst;
import com.weixing.mall.redis.order.OrderDivStock;
import org.redisson.api.RBlockingDeque;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class OrderDivStockRedissonQueueProducer {


    private RedissonClient redissonClient;

    @Autowired
    public OrderDivStockRedissonQueueProducer(RedissonClient redissonClient) {
        this.redissonClient = redissonClient;
    }


    public void producer(OrderDivStock payEnd) {
        //获取阻塞队列<名称和消费时获取名称一致>
        RBlockingDeque<OrderDivStock> blockingDeque = redissonClient.getBlockingDeque(RedisKeyConst.QUEUE_ORDER_DIV_STOCK);
        //将对象发送到redis队列
        blockingDeque.offer(payEnd);
    }
}